package com.winning.cjfw.service.service.impl;

import com.winning.cjfw.service.entity.dto.ClientRecordCount;
import com.winning.cjfw.service.entity.po.ClientRecord;
import com.winning.cjfw.service.mapper.ClientRecordMapper;
import com.winning.cjfw.service.service.ClientRecordService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.stream.Collectors;

/**
 * Author: yanxf@winning.com.cn
 * Description:
 * Date 2019/06/04 17:28
 */
@Service
@Slf4j
public class ClientRecordServiceImpl implements ClientRecordService {

    @Resource
    private ClientRecordMapper clientRecordMapper;

    @Override
    public void insert(ClientRecord clientRecord) {
        clientRecordMapper.insert( clientRecord );
    }

    @Override
    public void delete(List<ClientRecordCount> clientRecordList, String tablename) {
        List<String> lshs = clientRecordList.stream().map( record -> (tablename + record.getDate()) ).collect( Collectors.toList() );

        List<String> yljgdms = clientRecordList.stream().map( ClientRecordCount::getYljgdm ).collect( Collectors.toList() );
        clientRecordMapper.delete( lshs, yljgdms );
    }

}
